/**
 * 
 */
package com.qf.dao.impl;

import java.util.List;

import com.qf.common.dao.hibernate.HibernateCommonDAO;
import com.qf.dao.UserDao;
import com.qf.domain.User;

/**
 * @author 123
 * 
 */
public class UserDaoImpl extends HibernateCommonDAO implements UserDao {

	public List<User> listAll() {
		return super.findAll();
	}

	protected void initDao() throws Exception {
		super.initDao();
		this.setEntityClass(User.class);
	}

	public Integer add(User user) {
		return (Integer) super.create(user);
	}

	public User login(String userName, String password) {
		List<User> rs = super.find("from User u where u.userName='" + userName
				+ "' and password='" + password + "'");
		if (rs != null && rs.size() > 0) {
			return rs.get(0);
		} else {
			return null;
		}
	}

}
